using System;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;

namespace VisualPureBasicIDE.FormDesigner
{
    public class XmlSerializerSectionHandler : IConfigurationSectionHandler
    {
        #region IConfigurationSectionHandler Members

        object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section)
        {
            var navigator1 = section.CreateNavigator();

            if (navigator1 != null)
            {
                var text1 = (string) navigator1.Evaluate("string(@type)");
                var type1 = Type.GetType(text1);
                var serializer1 = new XmlSerializer(type1);
                return serializer1.Deserialize(new XmlNodeReader(section));
            }

            return null;
        }

        #endregion
    }
}